﻿Public Class KundeServiceImpl
    Inherits PersistenceServiceImpl(Of Kunde, KundeManager)
    Implements KundeService

    Sub New()
        MyBase.New(New KundeManagerImpl)
    End Sub

    Protected Overrides Sub beforeDelete(ByRef entity As Kunde)
        ' delete Projekte:
        Context.PROJEKT_SERVICE.deleteByKunde(entity)
    End Sub

    Protected Overrides Sub beforeSave(ByRef entity As Kunde)
        'save projekte
        For Each projekt As Projekt In entity.projekte
            Context.PROJEKT_SERVICE.save(projekt)
        Next
    End Sub

    Protected Overrides Sub fillUp(ByRef entity As Kunde)
        entity.projekte = Context.PROJEKT_SERVICE.findByKunde(entity)
        For Each projekt As Projekt In entity.projekte
            projekt.kunde = entity
        Next
    End Sub
End Class
